<template>
    <rx-dialog @handOk="handOk" @cancel="cancel">
        <rx-layout>
            <div slot="header">
                <div class="table-page-search-wrapper" border="false">
                    <a-form layout="inline">
                        <a-row :gutter="24">
                            <a-col :span="8">
                                <a-form-item :label="$ti18('rxForm.name','名称')">
                                    <a-input :placeholder="$ti18('rxForm.name','名称','','input')" v-model="queryParam.Q_NAME__S_LK"/>
                                </a-form-item>
                            </a-col>
                            <a-col :span="8">
                                <a-form-item :label="$ti18('rxForm.rxAlias','别名')">
                                    <a-input :placeholder="$ti18('rxForm.rxAlias','别名','','input')" v-model="queryParam.Q_ALIAS__S_EQ"/>
                                </a-form-item>
                            </a-col>
                            <a-col :span="8">
                              <span class="table-page-search-submitButtons">
                                <a-button type="primary" @click="$refs.table.loadData()" icon="search">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                                <a-button style="margin-left: 4px" @click="resetSearch">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                              </span>
                            </a-col>
                        </a-row>
                    </a-form>
                </div>
            </div>
            <div slot="center" style>
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="multiSelect"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formChartComponent/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="id"
                    @selectChange="onSelectChange"
                >
                </rx-grid>
            </div>
        </rx-layout>
    </rx-dialog>

</template>

<script>
import FormChartComponentApi from '@/api/form/core/formChartComponent'
import {BaseList, RxFit, RxGrid,Util} from "@lowcode/jpaas-common-lib";

export default {
    name: 'FormBusSolutionDialog',
    mixins: [BaseList],
    components: {
        RxFit
    },
    props: {
        layerid: {
            type: String,
            default: ""
        },
        destroy: {
            type: Function
        },
        multiSelect: {
            type: Boolean,
            default: false
        },
    },
    data() {
        return {
            columns: [
                {
                    title: this.$ti18('rxList.index','序号'),
                    type: 'indexColumn',
                    width: 100,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: this.$ti18('rxForm.name','名称'), dataIndex: 'name', width: 100},
                {title: this.$ti18('rxForm.rxAlias','别名'), dataIndex: 'alias', width: 100},
                {title: this.i18n('form.dataModel','数据模型'), dataIndex: 'dataModelName', width: 100}
            ],
        }
    },
    created(){
        let appId=this.curApp.appId;
        if (appId){
            this.queryParam["Q_APP_ID__S_EQ"]=appId;
        }
    },
    methods: {
        i18n(name, text, key) {
            return this.$ti18(name, text, "formChartComponent", key);
        },
        getListByParams(parameter) {
            return FormChartComponentApi.query(parameter)
        },
        handOk() {
            var rows = this.selectedRows;
            if (rows.length == 0) {
                this.$message.warning(this.$ti18("rxMsa.masWarn.selectOneRecord","请选择一行记录!"));
                return;
            }
            Util.closeWindow(this, "ok", rows[0]);
        },
        cancel() {
            Util.closeWindow(this, "cancel");
        },
        resetSearch(){
            this.$nextTick(() => {
                this.queryParam = {};
                let appId=this.curApp.appId;
                if (appId){
                    this.queryParam["Q_APP_ID__S_EQ"]=appId;
                }
                this.$nextTick(() => {
                    this.$refs.table.loadData();
                })
            })
        },
    }
}
</script>
<style scoped>

</style>

